﻿Imports TransportadoraToledoDAL
Imports System.Data
Imports System.Data.SqlClient
Public Class Cargas_AgendamentoBLL
    Dim objDAL As Cargas_agendamentoDAL
    Private age_codigo As Integer
    Public Property pAge_codigo() As Integer
        Get
            Return age_codigo
        End Get
        Set(ByVal value As Integer)
            age_codigo = value
        End Set
    End Property
    Private car_codigo As Integer
    Public Property pCar_codigo() As Integer
        Get
            Return car_codigo
        End Get
        Set(ByVal value As Integer)
            car_codigo = value
        End Set
    End Property
    Public Sub New()

    End Sub
#Region "Métodos"
    Public Sub inserirCargas()
        Try
            If (Me.age_codigo = 0) Then
                Throw New Exception("Código do agendamento não informado")
            ElseIf (Me.car_codigo = 0) Then
                Throw New Exception("Código da carga não informado")
            Else
                objDAL = New Cargas_agendamentoDAL
                objDAL.inserirCargas(Me.age_codigo, Me.car_codigo)
            End If
        Catch ex As Exception
            Throw ex
        End Try
        objDAL = Nothing
    End Sub
    Public Sub alterarCargas(ByVal age_codigo As Integer, ByVal age_carga As Integer)
        Try
            If (age_codigo = 0) Then
                Throw New Exception("Código do agendamento não informado")
            ElseIf (car_codigo = 0) Then
                Throw New Exception("Código da carga não informado")
            Else
                objDAL = New Cargas_agendamentoDAL
                objDAL.alterarCarga(Me.age_codigo, Me.car_codigo)
            End If
        Catch ex As Exception
            Throw ex
        End Try
        objDAL = Nothing
    End Sub
    Public Sub excluirCargas(ByVal age_codigo As Integer)
        Try
            If (age_codigo = 0) Then
                Throw New Exception("Código do agendamento não informado")
            Else
                objDAL = New Cargas_agendamentoDAL
                objDAL.excluirCarga(age_codigo)
            End If
        Catch ex As Exception
            Throw ex
        End Try
        objDAL = Nothing
    End Sub
    Public Function localizarCargas(ByVal age_codigo As Integer) As DataTable
        Dim tab As DataTable
        Try
            objDAL = New Cargas_agendamentoDAL
            tab = objDAL.localizarCargas(age_codigo)
        Catch ex As Exception
            Throw ex
        End Try
        objDAL = Nothing
        Return tab
    End Function
#End Region
End Class
